<template>
		<table class="table122" style="margin-top:10px;">
			<thead>
				<tr>
					<th class="w10 first" rowspan="3">
						<div class="out">
		                    <b>yttt</b>
		                    <em>ITEMS</em>
		                </div>
		               <!--  <span class="title1"></span><br><span class="title2">ITEMS</span> -->
					</th>
					<th class="w45" colspan="5">RECEIVABLE</th>
					<th class="w45" colspan="5">PAYABLE</th>
				</tr>
				<tr>
					<th class="w18" colspan="2">RMB</th>
					<th class="w17" colspan="2">USD</th>
					<th class="w9">TAX</th>
					<th class="w18" colspan="2">RMB</th>
					<th class="w17" colspan="2">USD</th>
					<th class="w10">TAX</th>
				</tr>
				<tr>
					<th class="w9">AMOUNT</th>
					<th class="w9">BILLING TO</th>
					<th class="w9">AMOUNT</th>
					<th class="8">BILLING TO</th>
					<th class="w10"></th>
					<th class="w9">AMOUNT</th>
					<th class="w9">BILLING TO</th>
					<th class="w9">AMOUNT</th>
					<th class="8">BILLING TO</th>
					<th class="w10"></th>
				</tr>
			</thead>
			<tbody>
				<!-- list -->
				<tr v-for="item in list">
					<td>{{item.itemen}}</td>
					<td class="tar">{{ cal_1(item) }}</td>
					<td>{{ item.corprmb0 }}</td>
					<td class="tar">{{ cal_2(item) }}</td>
					<td>{{ item.corpusd0 }}</td>
					<td>{{item.taxrate*100}}%<span class="fr">{{ cal_3(item) }}</span></td>
					<td class="tar">{{ cal_4(item) }}</td>
					<td>{{ item.corprmb1 }}</td>
					<td class="tar">{{ cal_5(item) }}</td>
					<td>{{item.corpusd1}}</td>
					<td>{{item.taxrate*100}}%	<span class="fr">{{ cal_6(item) }}</span></td>
				</tr>
				<!-- 统计 -->
				<tr>
					<td>SUB TOTAL</td>
					<td class="tar">{{sub_total.total_1.toFixed(2)}}</td>
					<td></td>
					<td class="tar">{{sub_total.total_2.toFixed(2)}}</td>
					<td></td>
					<td class="tar">{{sub_total.total_3.toFixed(2)}}</td>
					<td class="tar">{{sub_total.total_4.toFixed(2)}}</td>
					<td></td>
					<td class="tar">{{sub_total.total_5.toFixed(2)}}</td>
					<td></td>
					<td class="tar">{{sub_total.total_6.toFixed(2)}}</td>
				</tr>
				<tr>
					<td colspan="2">PROFIT/LOSS USD</td>
					<td colspan="9" class="tar">{{sub_total.profit}}</td>
				</tr>
			</tbody>
		</table>
</template>
<script setup lang="ts">

import { computed, onMounted, reactive } from "vue"


interface Props {
    bjno:string,
		data:anyObj,
		date:anyobj,
		op:anyObj
		list:any[]
}

const props = withDefaults(defineProps<Props>(), {
    bjno: '',
		data:{},
		date:{},
		op:{},
		list:()=>[]
})


//相关计算逻辑
const cal_1 = (item:any)=>{
	return (item.rmb0  / (1 + item.taxrate)).toFixed(2)
}

const cal_2 = (item:any)=>{
	return ((item.usd0 * item.usdrate  / (1 + item.taxrate))/item.usdrate).toFixed(2)
}

const cal_3 = (item:any)=>{
	return (item.rmb0 + (item.usd0*item.usdrate) -  (item.rmb0 + item.usd0*item.usdrate)  / (1 + item.taxrate)).toFixed(2)
}
const cal_4 = (item:any)=>{
	return (item.rmb1  /  ( 1 + item.taxrate)).toFixed(2)
}

const cal_5 = (item:any)=>{
	return ((item.usd1*item.usdrate / ( 1 + item.taxrate)) / item.usdrate).toFixed(2)
}
const cal_6 = (item:any)=>{
	return (item.rmb1 + (item.usd1*item.usdrate) -  (item.rmb1 + item.usd1*item.usdrate) / (1 + item.taxrate)).toFixed(2)
}
//总计相关
const sub_total = computed(()=>{
	let obj = {
		total_1:0,
		total_2:0,
		total_3:0,
		total_4:0,
		total_5:0,
		total_6:0,
		profit:0
	}
	props.list.map((item:any)=>{
		obj.total_1 += Number(cal_1(item))
		obj.total_2 += Number(cal_2(item))
		obj.total_3 += Number(cal_3(item))
		obj.total_4 += Number(cal_4(item))
		obj.total_5 += Number(cal_5(item))
		obj.total_6 += Number(cal_6(item))
	})
	let usdrate = props.list.length?props.list[0].usdrate:1
	obj.profit = Number((obj.total_2 - obj.total_5 + (obj.total_1 - obj.total_4) / usdrate).toFixed(2))

	return obj
})



</script>

<style lang="scss" scoped>
@import '../../../../styles/print.css';
</style>